﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _06.QuadricEquation
{
    class QuadricEquation
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Write the coeficients of quadric equation");
            Console.Write("a=  ");
            double a =double.Parse(Console.ReadLine());
            Console.Write("b= ");
            double b = double.Parse(Console.ReadLine());
            Console.Write("c= ");
            double c = double.Parse(Console.ReadLine());
            if (a == 0) 
            {
                Console.ForegroundColor = ConsoleColor.DarkRed;
                Console.WriteLine("a should be different than 0.Try again later!");
                return;
            }
            double d,x1,x2;
            d = Math.Pow(b, 2) - (4*a*c);
            if (d == 0)
            {
                x1 = (-b + Math.Sqrt(d)) / (2 * a);
                x2 = x1;
                Console.WriteLine("x1 = {0} \n x2 = {1}",x1,x2 );
            }
            else if (d > 0)
            {
                x1 = (-b + Math.Sqrt(d)) / (2 * a);
                x2 = (-b - Math.Sqrt(d)) / (2 * a);
                Console.WriteLine("x1 = {0} \n x2 = {1}", x1, x2);
            }
            else
            {
                Console.WriteLine("No real roots!!!");    
            }

        }
    }
}
